package com.ming.mapper;

import com.ming.pojo.entity.Dept;
import com.ming.pojo.vo.DeptListVO;
import com.ming.pojo.dto.DeptQueryDTO;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface DeptMapper {

    @Select("SELECT * FROM dept")
    List<Dept> list();

    List<Dept> listByCondition(DeptQueryDTO deptQueryDTO);

    List<DeptListVO> listVOByCondition(DeptQueryDTO deptQueryDTO);

    @Select("SELECT * FROM dept WHERE id = #{id}")
    Dept getById(Integer id);

    @Insert("INSERT INTO dept(name, create_time, update_time) VALUES (#{name}, #{createTime}, #{updateTime})")
    void insert(Dept dept);

    @Update("UPDATE dept SET name = #{name}, update_time = #{updateTime} WHERE id = #{id}")
    void update(Dept dept);

    @Delete("DELETE FROM dept WHERE id = #{id}")
    void deleteById(Integer id);

    @Select("SELECT * FROM dept WHERE name = #{name}")
    Dept getByName(String name);
}